#ifndef _HAL_UART_H
#define _HAL_UART_H

#include "Config.h"

#include "ch32v20x_gpio.h"

struct hal_buf_type{
  uint8_t *rxbuf;
  int8_t   state;
  uint32_t buf_size;
  uint32_t cnt;
};

struct hal_uart_type{
  void (*init)(uint32_t);
  void (*send)(uint8_t *,uint16_t);
  uint32_t (*get_cnt)(void);
  uint32_t (*get_buf)(uint8_t *);
  struct hal_buf_type buf;
};

extern struct hal_uart_type uart0;
extern struct hal_uart_type uart1;
extern struct hal_uart_type uart2;
extern struct hal_uart_type uart3;

extern void uart_set_buf(struct hal_uart_type *uart,uint8_t *buf,uint32_t buf_size);
#endif
